package com.xinzhitong.www.mapper;

import com.xinzhitong.www.pojo.ReceiptPlace;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * receipt_place表操作
 *
 * @author 徐鑫
 */
@Repository
public interface ReceiptPlaceMapper {

    @Select("select * from receipt_place where username=#{username}")
    List<ReceiptPlace> selectReceiptPlaceFrom(@Param("username") String username);

    @Insert("insert into receipt_place(name,phone,province,city,area,address,username) " +
            "value(#{receiptPlace.name}, #{receiptPlace.phone}, #{receiptPlace.province}, " +
            "#{receiptPlace.city}, #{receiptPlace.area}, #{receiptPlace.address}, #{receiptPlace.username})")
    Integer insertReceiptPlace(@Param("receiptPlace") ReceiptPlace receiptPlace);

    @Select("select * from receipt_place where id=#{id} and username=#{username}")
    ReceiptPlace selectTheReceiptPlace(Integer id, String username);

    @Update("update receipt_place set name=#{receiptPlace.name}, phone=#{receiptPlace.phone}, " +
            "province=#{receiptPlace.province}, city=#{receiptPlace.city}, area=#{receiptPlace.area}, " +
            "address=#{receiptPlace.address} where id=#{receiptPlace.id}")
    Integer updateTheReceiptPlace(@Param("receiptPlace") ReceiptPlace receiptPlace);

    @Delete("delete from receipt_place where id in ${ids}")
    Integer deleteTheReceiptPlace(@Param("ids") String ids);

}
